package com.xiao.service;

import com.xiao.domain.UserEntity;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @_PackageName:com.xiao.service
 * @_ClassName:UserService
 * @_Description:
 * @_Author：笑老二
 * @_data 2020/12/17 11:17
 */
@Service
public class UserService {

    @RabbitListener(queues = "atguigu.news")
    public void receive(UserEntity userEntity){
        System.out.println(userEntity);
    }

    @RabbitListener(queues = "atguigu")
    public void receive2(Message message){
        System.out.println(message.getBody());//获得消息内容
        System.out.println(message.getMessageProperties());//消息头信息
    }

}
